package cs3343.project.family.UI;

import javax.swing.JDialog;
import javax.swing.JOptionPane;

import cs3343.project.family.Card;
import cs3343.project.family.CardController;
import cs3343.project.family.Character;
import cs3343.project.family.ConfigManager;
import cs3343.project.family.GameController;

/**
 * The Class ToolCardFrame.
 */
public class ToolCardFrame extends JDialog {

	/** The gc. */
	private GameController gc;
	
	/** The card controller. */
	private CardController cardController;
	
	/**
	 * Instantiates a new tool card frame.
	 *
	 * @param character the character
	 * @param card the card
	 * @param cardType the card type
	 * @param gc the gc
	 */
	public ToolCardFrame(Character character, Card card, String cardType, GameController gc) {
		setModal(true);
		setResizable(false);
		this.gc = gc;
		this.gc.afterPressed();
		cardController = this.gc.getCardController();
		String msg = String.format(ConfigManager.getLangString("msgGetCard"), card.getName(), card.getDescription());
		JOptionPane.showMessageDialog(null, msg, ConfigManager.getLangString("toolCardFrameTitle"), 1);
		character.addCard(card);
	}
	
	/**
	 * Gets the tool card key.
	 *
	 * @param description the description
	 * @return the tool card key
	 */
	public int getToolCardKey(String description) {	
		for (int i = 1; i <= cardController.getNumOfMagicToolCard(); i++)
			if (cardController.getMagicToolCard(String.valueOf(i)).getDescription() == description)
				return i;		
		return 0;
	}
}
